<?php
namespace Home\Controller;
use Common\Controller\HomeBaseController;
use Common\Logic\UserLogic;
use Common\Logic\SmsLogic;
use Org\My\Page;
class IndexController extends HomeBaseController {
    
    protected $userLogic;
    protected $smsLogic;
    public function __construct() {
        parent::__construct();
        $this->userLogic = new UserLogic();
        $this->smsLogic = new SmsLogic();
    } 
    
    /*
     * pc首页
     */
    public function index(){ 
        //echo cookie('PCLogic');die; 
        $this->display();
    }
    
    /**
     * 检查短信验证码是否正确
     */
    public function checkVericode(){
        $vericode = I('vericode');
        $phone = I('phone');
        $result = $this->smsLogic->checkSmsVericode($phone,$vericode);
        if($result['error_code'] != 1){
            $this->ajaxReturn(true);
        }else{
            $this->ajaxReturn(false);
        }
    }
    
    /** 
     * 注册发送短信验证码
     */
    public function sendRegisterSms(){
        if(IS_GET){
            $mobile = I('mobile');
            sendSmsRegister($mobile);
        }
    }
    
    /**
     * 注册
     */
    public function register(){
       $mobile = I('mobile');
       $userpwd = I('pwd');
       $result = $this->userLogic->addUser($mobile,$userpwd);
       $this->ajaxReturn($result);
    }
    
    
    
    
    public function testPage(){
        /*$user = D('User');
        $limit = 2;
        $count=$user->where('')->count();
       
        $page=new Page($count,$limit);
        $list=$user->where('')->order('')->limit($page->firstRow.','.$page->listRows)->select();
        $show=$page->show();*/
        $pageData = handlePage('User',2);
        $this->assign('list',$pageData['list']);
        $this->assign('page',$pageData['show']);
        $this->display();
    }
    
    public function testSend(){
        $result = sendSmsRegister('13601097422');
        pp($result);
    }
    
    public function testExcel(){
        $data = array(
            array(NULL, 2010, 2011, 2012),
            array('Q1',   12,   15,   21),
            array('Q2',   56,   73,   86),
            array('Q3',   52,   61,   69),
            array('Q4',   30,   32,    0),
       );
 
        create_xls($data);
    }
    
    public function testQrcode(){
        qrcode('http://www.sx1211.cn/',16);
    }
    
    public function testFile(){
        $this->display();
        
    }
    
    public function uploadFile(){
       
        $config = C('FILE_UPLOAD_IMG_CONFIG');
         upload($_FILES, $config);
    }
    
}